Slider.isSupported = "undefined" != typeof document.createElement && "undefined" != typeof document.documentElement && "number" == typeof document.documentElement.offsetWidth;

function Slider(a, b, c) {
  if (a) {
    this._orientation = c || "horizontal";
    this._range = new Range;
    this._range.setExtent(0);
    this._unitIncrement = this._blockIncrement = 1;
    this._timer = new Timer(100);
    Slider.isSupported && a && (this.document = a.ownerDocument || a.document, this.element = a, this.element.slider = this, this.element.unselectable = "on", this.element.className = this._orientation + " " + this.classNameTag + " " + this.element.className, this.line = this.document.createElement("DIV"), this.line.style.padding = "0px", this.line.className = "line", this.line.unselectable = "on", this.line.appendChild(this.document.createElement("DIV")), this.element.appendChild(this.line), this.handle = this.document.createElement("DIV"), this.handle.className = "handle", this.handle.style.padding = "0px", this.handle.unselectable = "on", this.handle.appendChild(this.document.createElement("DIV")), this.handle.firstChild.appendChild(this.document.createTextNode(String.fromCharCode(160))), this.element.appendChild(this.handle));
    this.input = b;
    var d = this;
    this._range.onchange = function() {
      d.recalculate();
      if (typeof d.onchange == "function")d.onchange();
    };
    Slider.isSupported && a ? (this.element.onfocus = Slider.eventHandlers.onfocus, this.element.onblur = Slider.eventHandlers.onblur, this.element.onmousedown = Slider.eventHandlers.onmousedown, this.element.onmouseover = Slider.eventHandlers.onmouseover, this.element.onmouseout = Slider.eventHandlers.onmouseout, this.element.onkeydown = Slider.eventHandlers.onkeydown, this.element.onkeypress = Slider.eventHandlers.onkeypress, this.element.onmousewheel = Slider.eventHandlers.onmousewheel, this.handle.onselectstart = this.element.onselectstart = function() { return false }, this._timer.ontimer = function() { d.ontimer() }, window.setTimeout(function() { d.recalculate() }, 1)) : this.input.onchange = function() { d.setValue(d.input.value) };
  }
}

Slider.eventHandlers = {
  getEvent: function(a, b) {
    a || (a = b ? b.document.parentWindow.event : window.event);
    if (!a.srcElement) {
      for (b = a.target; null != b && 1 != b.nodeType;)b = b.parentNode;
      a.srcElement = b;
    }
    "undefined" == typeof a.offsetX && (a.offsetX = a.layerX, a.offsetY = a.layerY);
    return a;
  },
  getDocument: function(a) { return a.target ? a.target.ownerDocument : a.srcElement.document },
  getSlider: function(a) {
    for (a = a.target || a.srcElement; null != a && null == a.slider;)a = a.parentNode;
    return a ? a.slider : null;
  },
  getLine: function(a) {
    for (a = a.target || a.srcElement; null != a && "line" != a.className;)a = a.parentNode;
    return a;
  },
  getHandle: function(a) {
    for (var a = a.target || a.srcElement, b = /handle/; null != a && !b.test(a.className);)a = a.parentNode;
    return a;
  },
  onfocus: function() {
    var a = this.slider;
    a._focused = !0;
    a.handle.className = "handle hover";
  },
  onblur: function() {
    var a = this.slider;
    a._focused = !1;
    a.handle.className = "handle";
  },
  onmouseover: function(a) {
    var a = Slider.eventHandlers.getEvent(a, this), b = this.slider;
    a.srcElement == b.handle && (b.handle.className = "handle hover");
  },
  onmouseout: function(a) {
    var a = Slider.eventHandlers.getEvent(a, this), b = this.slider;
    a.srcElement == b.handle && !b._focused && (b.handle.className = "handle");
  },
  onmousedown: function(a) {
    var a = Slider.eventHandlers.getEvent(a, this), b = this.slider;
    b.element.focus && b.element.focus();
    Slider._currentInstance = b;
    var c = b.document;
    c.addEventListener ? (c.addEventListener("mousemove", Slider.eventHandlers.onmousemove, !0), c.addEventListener("mouseup", Slider.eventHandlers.onmouseup, !0)) : c.attachEvent && (c.attachEvent("onmousemove", Slider.eventHandlers.onmousemove), c.attachEvent("onmouseup", Slider.eventHandlers.onmouseup), c.attachEvent("onlosecapture", Slider.eventHandlers.onmouseup), b.element.setCapture());
    Slider.eventHandlers.getHandle(a) ? Slider._sliderDragData = { screenX: a.screenX, screenY: a.screenY, dx: a.screenX - b.handle.offsetLeft, dy: a.screenY - b.handle.offsetTop, startValue: b.getValue(), slider: b } : (c = Slider.eventHandlers.getLine(a), b._mouseX = a.offsetX + (c ? b.line.offsetLeft : 0), b._mouseY = a.offsetY + (c ? b.line.offsetTop : 0), b._increasing = null, b.ontimer());
  },
  onmousemove: function(a) {
    a = Slider.eventHandlers.getEvent(a, this);
    if (Slider._sliderDragData) {
      var b = Slider._sliderDragData.slider, c = b.getMaximum() - b.getMinimum(), d, e;
      "horizontal" == b._orientation ? (d = b.element.offsetWidth - b.handle.offsetWidth, e = a.screenX - Slider._sliderDragData.dx, a = 100 < Math.abs(a.screenY - Slider._sliderDragData.screenY)) : (d = b.element.offsetHeight - b.handle.offsetHeight, e = b.element.offsetHeight - b.handle.offsetHeight - (a.screenY - Slider._sliderDragData.dy), a = 100 < Math.abs(a.screenX - Slider._sliderDragData.screenX));
      b.setValue(a ? Slider._sliderDragData.startValue : b.getMinimum() + c * e / d);
      return!1;
    }
    b = Slider._currentInstance;
    null != b && (c = Slider.eventHandlers.getLine(a), b._mouseX = a.offsetX + (c ? b.line.offsetLeft : 0), b._mouseY = a.offsetY + (c ? b.line.offsetTop : 0));
  },
  onmouseup: function(a) {
    Slider.eventHandlers.getEvent(a, this);
    var a = Slider._currentInstance, b = a.document;
    b.removeEventListener ? (b.removeEventListener("mousemove", Slider.eventHandlers.onmousemove, !0), b.removeEventListener("mouseup", Slider.eventHandlers.onmouseup, !0)) : b.detachEvent && (b.detachEvent("onmousemove", Slider.eventHandlers.onmousemove), b.detachEvent("onmouseup", Slider.eventHandlers.onmouseup), b.detachEvent("onlosecapture", Slider.eventHandlers.onmouseup), a.element.releaseCapture());
    Slider._sliderDragData ? Slider._sliderDragData = null : (a._timer.stop(), a._increasing = null);
    Slider._currentInstance = null;
  },
  onkeydown: function(a) {
    var a = Slider.eventHandlers.getEvent(a, this), b = this.slider, a = a.keyCode;
    switch (a) {
    case 33:
      b.setValue(b.getValue() + b.getBlockIncrement());
      break;
    case 34:
      b.setValue(b.getValue() - b.getBlockIncrement());
      break;
    case 35:
      b.setValue("horizontal" == b.getOrientation() ? b.getMaximum() : b.getMinimum());
      break;
    case 36:
      b.setValue("horizontal" == b.getOrientation() ? b.getMinimum() : b.getMaximum());
      break;
    case 38:
    case 39:
      b.setValue(b.getValue() + b.getUnitIncrement());
      break;
    case 37:
    case 40:
      b.setValue(b.getValue() - b.getUnitIncrement());
    }
    if (33 <= a && 40 >= a)return!1;
  },
  onkeypress: function(a) {
    a = Slider.eventHandlers.getEvent(a, this);
    a = a.keyCode;
    if (33 <= a && 40 >= a)return!1;
  },
  onmousewheel: function(a) {
    var a = Slider.eventHandlers.getEvent(a, this), b = this.slider;
    if (b._focused)return b.setValue(b.getValue() + a.wheelDelta / 120 * b.getUnitIncrement()), !1;
  }
};
Slider.prototype.classNameTag = "dynamic-slider-control";
Slider.prototype.setValue = function(a) {
  this._range.setValue(a);
  this.input.value = this.getValue();
};
Slider.prototype.getValue = function() { return this._range.getValue() };
Slider.prototype.setMinimum = function(a) {
  this._range.setMinimum(a);
  this.input.value = this.getValue();
};
Slider.prototype.getMinimum = function() { return this._range.getMinimum() };
Slider.prototype.setMaximum = function(a) {
  this._range.setMaximum(a);
  this.input.value = this.getValue();
};
Slider.prototype.getMaximum = function() { return this._range.getMaximum() };
Slider.prototype.setUnitIncrement = function(a) { this._unitIncrement = a };
Slider.prototype.getUnitIncrement = function() { return this._unitIncrement };
Slider.prototype.setBlockIncrement = function(a) { this._blockIncrement = a };
Slider.prototype.getBlockIncrement = function() { return this._blockIncrement };
Slider.prototype.getOrientation = function() { return this._orientation };
Slider.prototype.setOrientation = function(a) { a != this._orientation && (Slider.isSupported && this.element && (this.element.className = this.element.className.replace(this._orientation, a)), this._orientation = a, this.recalculate()) };
Slider.prototype.recalculate = function() {
  if (Slider.isSupported && this.element) {
    var a = this.element.offsetWidth, b = this.element.offsetHeight, c = this.handle.offsetWidth, d = this.handle.offsetHeight, e = this.line.offsetWidth, f = this.line.offsetHeight;
    "horizontal" == this._orientation ? (this.handle.style.left = (a - c) * (this.getValue() - this.getMinimum()) / (this.getMaximum() - this.getMinimum()) + "px", this.handle.style.top = (b - d) / 2 + "px", this.line.style.top = (b - f) / 2 + "px", this.line.style.left = c / 2 + "px", this.line.style.width = Math.max(0, a - c - 2) + "px", this.line.firstChild.style.width = Math.max(0, a - c - 4) + "px") : (this.handle.style.left = (a - c) / 2 + "px", this.handle.style.top = b - d - (b - d) * (this.getValue() - this.getMinimum()) / (this.getMaximum() - this.getMinimum()) + "px", this.line.style.left = (a - e) / 2 + "px", this.line.style.top = d / 2 + "px", this.line.style.height = Math.max(0, b - d - 2) + "px", this.line.firstChild.style.height = Math.max(0, b - d - 4) + "px");
  }
};
Slider.prototype.ontimer = function() {
  var a = this.handle.offsetWidth, b = this.handle.offsetHeight, c = this.handle.offsetLeft, d = this.handle.offsetTop;
  if ("horizontal" == this._orientation)
    if (this._mouseX > c + a && (null == this._increasing || this._increasing))this.setValue(this.getValue() + this.getBlockIncrement()), this._increasing = !0;
    else {
      if (this._mouseX < c && (null == this._increasing || !this._increasing))this.setValue(this.getValue() - this.getBlockIncrement()), this._increasing = !1;
    }
  else if (this._mouseY > d + b && (null == this._increasing || !this._increasing))this.setValue(this.getValue() - this.getBlockIncrement()), this._increasing = !1;
  else if (this._mouseY < d && (null == this._increasing || this._increasing))this.setValue(this.getValue() + this.getBlockIncrement()), this._increasing = !0;
  this._timer.start();
};

function Range() {
  this._minimum = this._value = 0;
  this._maximum = 100;
  this._extent = 0;
  this._isChanging = !1;
}

Range.prototype.setValue = function(a) {
  a = Math.round(parseFloat(a));
  if (!isNaN(a) && this._value != a && (this._value = a + this._extent > this._maximum ? this._maximum - this._extent : a < this._minimum ? this._minimum : a, !this._isChanging && "function" == typeof this.onchange))this.onchange();
};
Range.prototype.getValue = function() { return this._value };
Range.prototype.setExtent = function(a) { if (this._extent != a && (this._extent = 0 > a ? 0 : this._value + a > this._maximum ? this._maximum - this._value : a, !this._isChanging && "function" == typeof this.onchange))this.onchange() };
Range.prototype.getExtent = function() { return this._extent };
Range.prototype.setMinimum = function(a) {
  if (this._minimum != a) {
    var b = this._isChanging;
    this._isChanging = !0;
    this._minimum = a;
    a > this._value && this.setValue(a);
    a > this._maximum && (this._extent = 0, this.setMaximum(a), this.setValue(a));
    a + this._extent > this._maximum && (this._extent = this._maximum - this._minimum);
    this._isChanging = b;
    if (!this._isChanging && "function" == typeof this.onchange)this.onchange();
  }
};
Range.prototype.getMinimum = function() { return this._minimum };
Range.prototype.setMaximum = function(a) {
  if (this._maximum != a) {
    var b = this._isChanging;
    this._isChanging = !0;
    this._maximum = a;
    a < this._value && this.setValue(a - this._extent);
    a < this._minimum && (this._extent = 0, this.setMinimum(a), this.setValue(this._maximum));
    a < this._minimum + this._extent && (this._extent = this._maximum - this._minimum);
    a < this._value + this._extent && (this._extent = this._maximum - this._value);
    this._isChanging = b;
    if (!this._isChanging && "function" == typeof this.onchange)this.onchange();
  }
};
Range.prototype.getMaximum = function() { return this._maximum };

function Timer(a) {
  this._pauseTime = "undefined" == typeof a ? 1E3 : a;
  this._timer = null;
  this._isStarted = !1;
}

Timer.prototype.start = function() {
  this.isStarted() && this.stop();
  var a = this;
  this._timer = window.setTimeout(function() { if ("function" == typeof a.ontimer)a.ontimer() }, this._pauseTime);
  this._isStarted = !1;
};
Timer.prototype.stop = function() {
  null != this._timer && window.clearTimeout(this._timer);
  this._isStarted = !1;
};
Timer.prototype.isStarted = function() { return this._isStarted };
Timer.prototype.getPauseTime = function() { return this._pauseTime };
Timer.prototype.setPauseTime = function(a) { this._pauseTime = a };